package com.palfund.touchevent;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        BigView bigView = (BigView) findViewById(R.id.bigView);
        NormalView normalView = (NormalView) findViewById(R.id.normalView);
        normalView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.i("normalView", "---onClick()--->" + "normalView");
            }
        });
        bigView.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                Log.i("bigView", "---onLongClick()--->" + "bigView");
                return false;
            }
        });
        normalView.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                Log.i("normalView", "---onTouch()--->" + event.getAction());
                return false;
            }
        });
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
        Log.i("MainActivity", "---dispatchTouchEvent()--->" + ev.getAction());
        return super.dispatchTouchEvent(ev);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        Log.i("MainActivity", "---onTouchEvent()--->" + event.getAction());
        return super.onTouchEvent(event);
    }

}
